package com.qf.service.impl;

import com.qf.dao.UserRepository;
import com.qf.pojo.User;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;

/**
 * @Description: 公用常量
 * @Data: 2022/9/15 15:07
 * @Pacakge: com.qf.service.impl
 * @ClassName: UserServiceImpl
 * @Author: fan
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserRepository userRepository;
    @Override
    public boolean findUserByUserName(User user, HttpSession httpSession) {
        System.out.println("user = " + user);
       User user1 =  userRepository.findUserByUsername(user.getUsername());
        System.out.println(user1);
       if (user1 == null || !user1.getPassword().equals(user.getPassword())){
           return false;
       }
        httpSession.setAttribute("user",user1);
        return true;
    }
}
